package com.iceengine.j3d.container;

/**
 * The Node class manages a world that is build of ObjectContainers.
 * @author penguin
 */
import java.util.ArrayList;
import org.lwjgl.util.vector.Vector3f;
import org.lwjgl.opengl.GL11;

import com.iceengine.j3d.camera.ICamera;

public class Node {
    private ArrayList<ObjectContainer> theObjects;
    private ICamera myCamera;
    int[] fogMode = {GL11.GL_EXP, GL11.GL_EXP2, GL11.GL_LINEAR };

    /**
     * Initializes the node
     * @param theCamera The cameraclass you want to use.
     */
    public Node(ICamera theCamera)
    {
        theObjects = new ArrayList<ObjectContainer>();
        myCamera = theCamera;
    }

    /**
     * Initializes the node.
     */
    public Node()
    {
        theObjects = new ArrayList<ObjectContainer>();
        myCamera = null;
    }

    /**
     * Adds an ObjectContainer to the node.
     * @param toAdd ObjectContainer to add.
     */
    public void addObjectContainer(ObjectContainer toAdd)
    {
        theObjects.add(toAdd);
    }

    /**
     * Draws the Node.
     */
    public void draw()
    {
        Vector3f translation = new Vector3f(0,0,0), rotation = new Vector3f(0,0,0);
        if(myCamera != null)
        {
            translation = myCamera.getTranslation();
            rotation = myCamera.getRotation();
        }

        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        for(int i = 0; i < theObjects.size(); i++)
        {

            theObjects.get(i).drawContainer(translation, rotation);
        }
    }

}
